<template>
  <Layout>
    <Ctable
      v-loading="students.loading"
      :data="students.list"
      :order="false"
      :selection="false"
      :total="students.query.total_"
      :pageSize="students.query.pageSize_"
      :pageNum="students.query.pageNum_"
      :paginationShowRefresh="true"
      :fetchData="getData"
    >
      <el-table-column
        prop="studentId"
        label="学号"
        fixed="left"
        width="100px"
      />
      <el-table-column prop="name" label="姓名" width="100px" />
      <el-table-column
        prop="facultyI18n"
        label="学院"
        show-overflow-tooltip
        width="100px"
      />
      <el-table-column prop="statue" label="入学年级" />
      <el-table-column prop="cultureProfessionI18n" label="培养专业" />
      <el-table-column prop="trainingLevelI18n" label="培养类别" />
      <el-table-column prop="campusI18n" label="校区" />
      <el-table-column label="操作" fixed="right" width="120">
        <template #default="scope">
          <el-link type="primary" @click="viewDetail(scope.row)"
            >detail</el-link
          >
        </template>
      </el-table-column>
    </Ctable>
  </Layout>
</template>

<script setup>
import api from "@/api/index";
import { useRouter } from "vue-router";

const router = useRouter();

// table列表业务
const students = reactive({
  list: [],
  loading: false,
  query: {
    total_: 0,
    pageSize_: 7,
    pageNum_: 1,
    // teacherCodeAndName: '00001',
  },
});

let getData = async (data) => {
  if (data && data.pageNum) {
    students.query.pageNum_ = data.pageNum;
  }
  if (data && data.pageSize) {
    students.query.pageSize_ = data.pageSize;
  }
  students.loading = true;
  let res = await api.student.findStuInfoList(students.query);
  students.loading = false;
  students.list = res.data.list;
  students.query.total_ = res.data.total_;
};

// let handleCurrentChange = (pages) => {
//   console.log("handleCurrentChange");
//   // students.query.pageNum_ = pages.pageNum;
//   // students.query.pageSize_ = pages.pageSize;
//   // getData();
// };
// let handleSelectionChange = (row, expandedRows) => {
//   console.log("handleSelectionChange");
//   // console.log(row);
// };
// table列表业务 End

let viewDetail = (row) => {
  console.log(row);
  router.push({
    path: "/page2/" + row.studentId,
  });
};
</script>

<style lang="scss" scoped></style>
